package com.ericsson.resourceplanner.web;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ericsson.resourceplanner.dao.entity.Role;
import com.ericsson.resourceplanner.dto.EmployeeDtlsVO;
import com.ericsson.resourceplanner.service.ChangeRoleService;




@Controller
public class ChangeRoleController {
	
	private final static Logger logger = LoggerFactory.getLogger(ChangeRoleController.class);
	private final static String CLASS_NAME = ChangeRoleController.class.getSimpleName();
	  
	  
    @Autowired
	 ChangeRoleService changeRoleService ;
	  
	
    
	public ChangeRoleService getChangeRoleService() {
		return changeRoleService;
	}


	public void setChangeRoleService(ChangeRoleService changeRoleService) {
		this.changeRoleService = changeRoleService;
	}


	//  @RequestMapping(value ="/" , method = RequestMethod.GET)
	  @RequestMapping(value ="/EmpDetails",method = RequestMethod.GET)
	  public @ResponseBody List<EmployeeDtlsVO> getEmpDetails(){
		  

		   return changeRoleService.getEmpList();
		
		  
	  }
	  
	  @RequestMapping(value ="/RoleDetails",method = RequestMethod.GET)
	  public @ResponseBody List<Role> geRoleDetails(){
		  
		         
		  return changeRoleService.getRoleList();
		
		  
	  }
	  
	  @RequestMapping(value ="/ProcessGridData",method = RequestMethod.POST)
	  
	  public @ResponseBody void processUpdateRoleData(@RequestBody EmployeeDtlsVO[] role_data){
		  
/*
		  for(int i= 0 ;i<role_data.length;i++){
			  System.out.println("ID:"+role_data[i].getId()+"Name:"+role_data[i].getEmploye_Name());
			    for(int j= 0 ;j<role_data[i].getEmp_rolelist().size();j++){
			     System.out.println("Role Id:"+role_data[i].getEmp_rolelist().get(j));	
			    }
		  }*/
		  
		  changeRoleService.updateRole(role_data);
	  }
	  
	  
	   @RequestMapping(value = "/changerole", method = RequestMethod.GET)
		public String home(Locale locale, Model model) {
			
			return "changeRole";
		}
		

}
